package org.geometerplus.android.fbreader;

import android.content.Intent;

import org.geometerplus.android.fbreader.api.FBReaderIntents;
import org.geometerplus.android.fbreader.bookmark.EditBookmarkActivity;
import org.geometerplus.android.fbreader.libraryService.BookCollectionShadow;
import org.geometerplus.android.util.OrientationUtil;
import org.geometerplus.fbreader.book.Bookmark;
import org.geometerplus.fbreader.fbreader.FBReaderApp;

/**
 * author : wangliang
 * date   : 2021/11/17 0017上午 10:57
 * desc   :笔记
 */
class SelectionNoteAction extends FBAndroidAction {
    private final BookCollectionShadow myCollection = new BookCollectionShadow();

    public SelectionNoteAction(FBReader baseActivity, FBReaderApp fbreader) {
        super(baseActivity, fbreader);
    }

    @Override
    protected void run(Object... params) {
        final Bookmark bookmark;
        if (params.length != 0) {
            bookmark = (Bookmark) params[0];
        } else {
            bookmark = Reader.addSelectionBookmark();
        }
        if (bookmark == null) {
            return;
        }
        bookmark.setText("");

        Intent intent =
                new Intent(BaseActivity.getApplicationContext(), EditBookmarkActivity.class);
        FBReaderIntents.putBookmarkExtra(intent, bookmark);
        OrientationUtil.startActivity(BaseActivity, intent);
//        myCollection.bindToService(BaseActivity, new Runnable() {
//            public void run() {
//                myCollection.saveBookmark(bookmark);
//            }
//        });

    }
}
